package com.anbang.app.ui.guide

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.fragment.app.Fragment
import com.anbang.app.R
import com.bumptech.glide.Glide

/**
 * @Description:
 * @Author: AnBang
 * @Date: 2019/1/11 19:12
 */
class GuideTranslateFragment : Fragment() {

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {

        var layoutId = arguments?.getInt(GuideViewPagerAdapter.KEY_LAYOUT_ID)

        var position = arguments?.getInt(GuideViewPagerAdapter.KEY_POSITION)

        if (layoutId == null) {
            layoutId = R.layout.fragment_guide_0
        }

        if (position == null) {
            position = 0
        }

        val pg1 = arrayOf(R.drawable.pg1_1, R.drawable.pg2_1, R.drawable.pg3_1)
        val pg2 = arrayOf(R.drawable.pg1_2, R.drawable.pg2_2, R.drawable.pg3_2)

        return inflater.inflate(layoutId, null).apply {
            tag = position
            val bg1Iv = findViewById<ImageView>(R.id.bg1Iv)
            val bg2Iv = findViewById<ImageView>(R.id.bg2Iv)

            Glide.with(this).load(pg1[position]).into(bg1Iv)
            Glide.with(this).load(pg2[position]).into(bg2Iv)
        }
    }
}